﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HXDNB.DAL;
using HXDNB.Infrastructure;
using HXDNB.CMS.App_Code;
namespace HXDNB.CMS.Controllers
{
    public class SystemController : BaseController
    {

        //日志列表        
        public ActionResult List(string type, int index = 0)
        {
            LogBLL Bll = new LogBLL();
            IQueryable<HXDNB.DAL.Logs> List = Bll.GetList(type == "ALL" ? null : type);
            Paging<HXDNB.DAL.Logs> Pag = new Paging<HXDNB.DAL.Logs>(List);
            ViewBag.PagList = Pag;
            return View();
        }
        //日志删除
        [HttpPost]
        public string Delete()
        {
            LogBLL Bll = new LogBLL();
            bool result = true;
            result = Bll.Delete(DateTime.Now.AddMonths(-3));
            return result.ToString();
        }
        public ActionResult Setting()
        {
            WebSettingBLL bll = new WebSettingBLL();
            var info = new WebSetting();
            info = bll.GetByKey(1);
            return View(info);
        }

        [HttpPost, ValidateInput(false)]
        public ActionResult Setting(WebSetting info)
        {
            WebSettingBLL bll = new WebSettingBLL();
            bool result = false;
            info.ID = 1;
            result = bll.update(info);
            return RedirectToAction("Info", new { id = info.ID, result = result ? "Y" : "N" });
        }
    }
}
